import { request } from "@/utils/request"
import qs from 'querystring'

const prefix = '/parkingLot'

interface addParkingLotParams {
	id: number,
	building: string,
	storey: number,
	x: number,
	y: number,
	status: number,
	type: number
	picture: string
}
/**
 * 添加车位
 * @param params 车位信息
 * @returns 
 */
export const addParkingLotRequest = (params: addParkingLotParams) => {
	return request.post(`${prefix}/addParkingLot`, params)
}

/**
 * 获取所有车位
 * @returns 
 */
export const getParkingLotReuqest = () => {
	return request.get(`${prefix}/getParkingLot`)
}

/**
 * 删除车位
 * @param id 车位id
 * @returns 
 */
export const deleteParkingLotRequest = (params: number) => {
	return request.delete(`${prefix}/deleteParkingLot/${params}`)
}

/**
 * 修改车位
 * @param params 
 * @returns 
 */
export const reviseParkingLotRequest = (params: addParkingLotParams) => {
	return request.put(`${prefix}/reviseParkingLot`, params)
}

interface searchParams {
	[s: string]: any;
	storey: number | undefined,
	x: number | undefined,
	y: number | undefined,
	status: 0 | 1 | undefined,
	type: number | undefined
}
/**
 * 根据条件筛选车位
 * @param params 
 * @returns 
 */
export const searchParkingLotRequest = (params: searchParams) => {
	return request.get(`${prefix}/searchParkingLot?${qs.stringify(params)}`)
}